package a8;

public class FactorGenerator {
	/**
	 * Create new constructor
	 * @param numberToFactor
	 */
	public FactorGenerator(int numberToFactor) {
		num = numberToFactor;
		factors = true;
		i = 2;
		div = num;
	}
	/**
	 * 
	 * @return The next factor
	 */
	public void nextFactor(){
		for(i = 2 ; i <= Math.sqrt(num); i++)
		{
			if(div%i == 0)
			{
				div /= i;
				System.out.println(i);
				return;
			}
		}
		factors = false;
	}
	/**
	 * 
	 * @return Verify if there are more factors
	 */
	public boolean hasMoreFactors() {
		return factors;	
	}
	
	
	private int num;
	private boolean factors;
	private int i;
	private int div;
}
